/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.assignment.Qusetion1.invoice;

import za.ac.cput.assignment.Qusetion1.payable.Payable;

/**
 *
 * @author Andisiwe
 */

public final class Invoice implements Payable
{
    private String partNumber;
    private String partDescription;
    private int quantity;
    private double pricePerItem;
    
    
    public Invoice(String part, String description, int count, double price)
    {
        partNumber = part;
        partDescription = description;
        setQuantity (count);
        setPricePerItem(price);
        
        
    }

    /**
     * @return the partNumber
     */
    public String getPartNumber()
    
    {
        return partNumber;
    }

    /**
     * @param partNumber the partNumber to set
     */
    public void setPartNumber(String partNumber)
    {
        this.partNumber = partNumber;
    }

    /**
     * @return the partDescription
     */
    public String getPartDescription() {
        return partDescription;
    }

    /**
     * @param partDescription the partDescription to set
     */
    public void setPartDescription(String partDescription) {
        this.partDescription = partDescription;
    }

    /**
     * @return the quantity
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(int count)
    {
        this.quantity = (count < 0 )? 0: count;
    }

    /**
     * @return the pricePerItem
     */
    public double getPricePerItem() 
    {
        return pricePerItem;
    }

    /**
     * @param pricePerItem the pricePerItem to set
     */
    public void setPricePerItem(double price) 
    {
        this.pricePerItem = (price < 0.0)?0.0: price;
    }

    @Override
    public String toString() 
    {
        return String.format("%s:\n%s:(%s)\n%s: %d \n%: $%,2f",
                            "invoice ", "part number",getPartNumber (), getPartDescription(),
                            "quantity", getQuantity(), "price per item",getPricePerItem());
    }
   @Override
   public double getPaymentAmount()
   {
       return getQuantity()* getPricePerItem();
   }
    
   
}
    
   